<%@ page language="java" pageEncoding="utf8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<c:url value="/css/shopadmin.css"/>" type="text/css" />
		<link rel="stylesheet" href="<c:url value='/scripts/themes/base/jquery.ui.all.css'/>" type="text/css" />
		<link rel="stylesheet" href="<c:url value='/scripts/skin/ui.dynatree.css'/>" type="text/css" />

	</head>
	<body style="">
		<div id="headBar" class="head_content"></div>
		<div id="main" class="main_content">
			<form method="post" id="model_form" action="sys_delivery_type_save.html">
				<input type="hidden" name="orderDeliveryType.dtId" value="${orderDeliveryType.dtId}" />
				<div class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									配送方式名称:
								</th>
								<td>
									<input type="text" class="_x_ipt" value="${orderDeliveryType.dtName}" name="orderDeliveryType.dtName" />
								</td>
								<th>
									选择默认物流公司:
								</th>
								<td>
									<select id="corp_id" name="orderDeliveryType.corpId">
										<option value="0">
											请选择物流公司
										</option>
										<c:forEach items="${orderDeliveryCorps}" var="corp">
											<option value="${corp.corpId}">
												${corp.corpName}
											</option>
										</c:forEach>
									</select>
								</td>
							</tr>
							<tr>
								<th>
									类型:
								</th>
								<td>
									<label>
										<input type="radio" checked="" value="false" name="orderDeliveryType.hasCod">
											先收款后发货 
									</label>
									&nbsp;
									<label>
										<input type="radio" value="true" name="orderDeliveryType.hasCod">
											货到付款 
									</label>
									<span class="notice-inline">选择货到付款后顾客无需再选择支付方式</span>
								</td>
							</tr>
							<tr>
								<th>
									重量设置:
								</th>
								<td>
									首重重量
									<input type="text" class="_x_ipt" style="width: 80px;" value="${orderDeliveryType.basicUnit }" name="orderDeliveryType.basicUnit" />
									公斤 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 续重单位&nbsp;
									<input type="text" class="_x_ipt" style="width: 80px;" value="${orderDeliveryType.additionalUnit}" name="orderDeliveryType.additionalUnit" />
									公斤
								</td>
								<th>
									&nbsp;
								</th>
								<td>
									&nbsp;
								</td>
							</tr>
							<tr>
								<th>
									&nbsp;
								</th>
								<td>
									<input onclick="setProtectRate(this)" id="is_protect" type="checkbox" value="true" <c:if test="${orderDeliveryType.protect }">checked="checked"</c:if> name="orderDeliveryType.protect">
										支持物流保价 
								</td>
								<th>
									&nbsp;
								</th>
								<td>
									&nbsp;
								</td>
							</tr>
							<tr id="protectrate" style="display: none;">
								<th>
									保价设置:
								</th>
								<td>
									费率&nbsp;
									<input type="text" class="_x_ipt" style="width: 50px;" value="${orderDeliveryType.protectRate }" name="orderDeliveryType.protectRate">
										%&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最低保价费&nbsp; <input type="text" class="_x_ipt" style="width: 50px;" value="${orderDeliveryType.protectMinPrice}"
											name="orderDeliveryType.protectMinPrice">
								</td>
								<th>
									&nbsp;
								</th>
								<td>
									&nbsp;
								</td>
							</tr>
							<tr>
								<th>
									地区费用类型:
								</th>
								<td>
									<div id="deliveryAreaToggle">
										<label>
											<input type="radio" onclick="dtSubAreaSetting(this)" <c:if test="${orderDeliveryType.sameSetOn }">checked="checked"</c:if> value="true" name="orderDeliveryType.sameSetOn" />
											统一设置
										</label>
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<label>
											<input type="radio" onclick="dtSubAreaSetting(this)" <c:if test="${!orderDeliveryType.sameSetOn }">checked="checked"</c:if> value="false" name="orderDeliveryType.sameSetOn" />
											指定配送地区和费用

										</label>
									</div>
								</td>
								<th>
									&nbsp;
								</th>
								<td>
									&nbsp;
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div id="def_dexp" class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<input type="hidden" value="0" name="price">
							<tbody>
								<tr>
									<th>
										配送费用:
									</th>
									<td>
										<div class="deliveryexpbox" style="line-height: 30px;">
											<div style="" class="deliveryexp">
												首重费用
												<input class="_x_ipt" value="${orderDeliveryType.basicFee }" name="orderDeliveryType.basicFee" style="width: 60px; margin-right: 20px;" />
												续重费用
												<input class="_x_ipt" value="${orderDeliveryType.additionalFee}" name="orderDeliveryType.additionalFee" style="width: 60px;" />

											</div>
											<div style="display: none;" class="deliveryexp">
												配送公式
												<input type="text" class="_x_ipt" value="${orderDeliveryType.dtExpressions }" name="orderDeliveryType.dtExpressions" style="width: 300px;">
													<span onclick="checkExp(this);" class="checkexp sysiconBtnNoIcon">验证</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span onclick="chaexps(this)" class="lnk chgexp">取消公式</span> <input
														type="hidden" value="0" name="dt_useexp">
											</div>
										</div>
									</td>
								</tr>
							</tbody>
					</table>
				</div>

				<div id="deliveryAreabox" class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									支持的配送地区:
								</th>
								<td>
									<div class="deliveryArea" id="deliveryArea-">
										<c:if test="${not empty orderDeliveryTypeAreas}">
											<ol style="list-style: decimal outside none;">
												<c:forEach items="${orderDeliveryTypeAreas}" var="orderDeliveryTypeArea">
													<li style="line-height: 30px;" class="division">
														<div class="deliverycity">
															<span onclick="deleteDeliveryArea(this,${orderDeliveryTypeArea.dtaId})" style="float: right;"> <img class="imgbundle"
																	style="width: 16px; height: 16px; background-position: 0pt -214px; cursor: pointer;" src="<c:url value="/images/transparent.gif"/>" /> </span>
															<a style="font-weight: bold;" href="sys_delivery_type_area_edit.html?dtId=${orderDeliveryType.dtId}&dtaId=${orderDeliveryTypeArea.dtaId}">编辑该改组配置</a>
															<br />
															${orderDeliveryTypeArea.areaNameGroup}
														</div>
														<div class="deliveryexpbox">
															<div class="deliveryexp" style="">
																首重费用${orderDeliveryTypeArea.basicFee }&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;  续重费用 ${orderDeliveryTypeArea.additionalFee}
															</div>
														</div>
													</li>
												</c:forEach>
											</ol>
										</c:if>


										<span class="sysiconBtn add"><a style="text-decoration:none;" href="sys_delivery_type_area_add.html?dtId=${orderDeliveryType.dtId}">添加更多的地区设置运费</a>
										</span>

									</div>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									排序:
								</th>
								<td>
									<input type="text" class="_x_ipt" value="${orderDeliveryType.showOrder}" id="ordernum" name="orderDeliveryType.showOrder" />
								</td>
							</tr>
							<tr>
								<th>
									状态:
								</th>
								<td>
									<input type="radio" value="true" <c:if test="${orderDeliveryType.dtStatus }">checked="checked"</c:if> name="orderDeliveryType.dtStatus" />
									启用
									<input type="radio" value="false" <c:if test="${!orderDeliveryType.dtStatus }">checked="checked"</c:if> name="orderDeliveryType.dtStatus" />
									关闭
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="division">
					<table width="100%" cellspacing="0" cellpadding="0" border="0">
						<tbody>
							<tr>
								<th>
									详细介绍:
								</th>
								<td>
									<textarea rows="5" cols="30" name="orderDeliveryType.detail">${orderDeliveryType.detail }</textarea>
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="table-action">
					<button class="btn" type="submit">
						<span><span>保存</span> </span>
					</button>
				</div>
			</form>
		</div>

		<div id="footBar" class="foot_content"></div>



		<script type="text/javascript" src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/jquery.validate.js'/>"></script>


		<script type="text/javascript">
		
 
 
 	<c:if test="${not empty orderDeliveryType.dtId}">
 		$('#corp_id').attr('value','${orderDeliveryType.corpId}'); 
 		setProtectRate($('#is_protect'));
	 </c:if>
 
 function setProtectRate(dom){
 	if($(dom).attr("checked")){
 		$('#protectrate').css('display','');
 	}else{
 		$('#protectrate').css('display','none'); 	
 	}
 
 }
 
	$(document).ready(function() {
		var validator = $("#model_form").validate( {
			errorElement : "div",
			errorClass : "x-vali-error",
			onfocusout : false,
			rules : {
				'orderDeliveryType.dtName' : "required" ,
				'orderDeliveryType.detail' : "required" ,
				'orderDeliveryType.showOrder' : {
					required : true,
					number : true
				},
				'orderDeliveryType.basicUnit' : {
					required : true,
					number : true
				},
				'orderDeliveryType.additionalUnit' : {
					required : true,
					number : true
				},
				'orderDeliveryType.basicFee' : {
					required : true,
					number : true
				},
				'orderDeliveryType.additionalFee' : {
					required : true,
					number : true
				} ,
				'orderDeliveryType.protectRate' : {
					required : true,
					number : true
				},
				'orderDeliveryType.protectMinPrice' : {
					required : true,
					number : true
				} 
			},
			messages : {
				'orderDeliveryType.dtName' : "必填字段" ,
				'orderDeliveryType.detail' : "必填字段" ,
				'orderDeliveryType.showOrder' : {
					required : "必填字段",
					number : "请填入数字"
				},
				'orderDeliveryType.basicUnit' : {
					required : "必填字段",
					number : "请填入数字"
				},
				'orderDeliveryType.additionalUnit' : {
					required : "必填字段",
					number : "请填入数字"
				},
				'orderDeliveryType.basicFee' : {
					required : "必填字段",
					number : "请填入数字"
				},
				'orderDeliveryType.additionalFee' : {
					required : "必填字段",
					number : "请填入数字"
				} ,
				'orderDeliveryType.protectRate' : {
					required : "必填字段",
					number : "请填入数字"
				},
				'orderDeliveryType.protectMinPrice' : {
					required : "必填字段",
					number : "请填入数字"
				} 
			},
			errorPlacement : function(error, element) {
				element.removeClass('x-vali-error');
				error.appendTo(element.parent());

			},

			success : function(div) {
				$(div).remove();
			}
		});
	});
	
	
	
	function deleteDeliveryArea(obj,dtaId) {
		var url = "sys_delivery_type_area_delete.html";
			var params = {
				"dtaId" : dtaId
			};

			$.getJSON(url, params, 
				function callback(data) 
				{	
					$(obj).parent().parent().remove();
				}
			);
	}
	
	
</script>
	</body>
</html>